<template>
    <div class="app-container">
      <Form
        v-if="showSearch"
        v-model:formData="searchInfo"
        :formItems="formItems"
      >
        <template #footer>
          <div style="text-align: left">
            <el-button size="small" icon="Search" type="primary" @click="goSearch"
              >搜索</el-button
            >
            <el-button size="small" icon="Refresh" @click="resetSearch"
              >重置</el-button
            >
          </div>
        </template>
      </Form>
      <h3>
        <!-- <el-button size="small" icon="Plus" @click="add" type="primary"
          >添加</el-button
        > -->
      </h3>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5"> </el-col>
        <right-toolbar
          v-model:showSearch="showSearch"
          @queryTable="resetSearch"
        ></right-toolbar>
      </el-row>
      <h3></h3>
      <x-table
        :propList="propList"
        :tableData="info.items"
        :isLoading="isLoading"
      >
        <template #type="{ row }">
          <el-tag v-if="row.type == 1" type="success">加款</el-tag>
          <el-tag v-if="row.type == 2" type="danger">扣款</el-tag>
        </template>
        <template #op="{ row }">
          <el-button type="primary" link icon="Edit" @click="change(row)"
            >编辑</el-button
          >
          <el-button type="primary" link icon="Delete" @click="del(row)"
            >删除</el-button
          >
        </template>
      </x-table>
      <pagination
        v-show="info.total > 0"
        :total="info.total"
        v-model:page="searchInfo.pageNum"
        v-model:limit="searchInfo.pageSize"
        @pagination="getInfo"
      />
      <Dialog width="30%" title="内容" v-model:isShowDialog="isShowDialog">
        <div>
          <p>{{ curItem.content }}</p>
        </div>
        <!-- <Form ref="formRef" v-bind="dialogConfig.formConfig"> </Form> -->
      </Dialog>
    </div>
  </template>
  
  <script>
  import { propList, formItems } from "./config";
  import { getBalanceLog } from "@/api/platform/mpUser";
  export default {
    // name: "mpmpUserBalanceLogindex",
    name:"platformuserBalanceLogindex",
    data() {
      return {
        //   dialogConfig,
        curItem: {},
        showSearch: true,
        isShowDialog: false,
        isLoading: false,
        propList,
        formItems,
        info: {},
        searchInfo: {
          pageNum: 1,
          pageSize: 10,
          created_at: this.getTimeFilterDefault(true),
        },
      };
    },
    computed: {},
    created() {
      this.init();
    },
    //   mounted() {},
    methods: {
      init() {
        this.mp_user_id = this.$route.query.id;
        if (!this.mp_user_id) {
          this.$message.error("非法进入,请返回!");
          return false;
        }
        this.getInfo();
      },
      async getInfo() {
        this.isLoading = true;
        const params = { ...this.searchInfo };
        params.mp_user_id = this.mp_user_id;
        const { data } = await getBalanceLog(params);
        this.info = data;
        this.isLoading = false;
      },
      resetSearch() {
        this.searchInfo = this.$options.data.call(this).searchInfo;
        this.searchInfo.created_at = this.getTimeFilterDefault(true);
        this.getInfo();
      },
      goSearch() {
        // 重置时间
        this.getInfo();
      },
      add() {
        // 添加
        this.dialogConfig.formConfig.formData = {};
        this.isShowDialog = true;
      },
      change(item) {
        // 修改
        this.dialogConfig.formConfig.formData = { ...item };
        this.isShowDialog = true;
      },
      del(item) {
        // 删除
      },
    },
  };
  </script>
  
  <style lang="scss" scoped></style>
  